home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 015 / epsilon.arc / BETTERC.ARC / PROC.E < prev   
Encoding:
Text File  |  1986-01-04  |  4.5 KB  |  179 lines

  1. /************************************************************************
  2. * "Epsilon", "EEL" and "Lugaru" are trademarks of Lugaru Software, Ltd. *
  3. *                                    *
  4. *     Copyright (C) 1985 Lugaru Software Ltd.  All rights reserved.    *
  5. *                                    *
  6. * Limited permission is hereby granted to reproduce and modify this    *
  7. * copyrighted material provided that the resulting code is used only in    *
  8. * conjunction with Lugaru products and that this notice is retained in    *
  9. * any such reproduction or modification.                *
  10. ************************************************************************/
  11.  
  12. /*
  13.  *  Modifications copyright (c) 1985 by David Dyer-Bennet
  14.  *  Permission for non-commercial use is hereby granted; all other
  15.  *  rights are reserved.
  16.  *
  17.  *  Modifications by David Dyer-Bennet
  18.  *  Terrabit Software
  19.  *  4242 Minnehaha Ave S
  20.  *  Minneapolis, MN 55406
  21.  *  Sysop of Fido 14/341, The Terraboard, (612) 721-8967 3/12/24 24hrs
  22.  *  (612) 721-8800 NOT 24 hrs!  More like noon to midnight
  23.  */
  24.  
  25. /*
  26.  *  Revision history:
  27.  *
  28.  *      Edit    Date        Who     Description
  29.  *
  30.  *  Version 1.0
  31.  *      0       12-Nov-85   Lugaru  Epsilon Version 3.01
  32.  *      1       3-Jan-86    DD-B    Make error recognizer flexible
  33.  */
  34.  
  35. #include "eel.h"
  36.  
  37. buffer char *error_recog;    /* [1] How to recognize a compiler error */
  38. buffer char *erfile_recog;    /* [1] How to recognize the file */
  39.                 /* group 1 must be file name */
  40. buffer char *erline_recog;    /* [1] How to recognize the line no. */
  41.                 /* group 1 must be line number */
  42.  
  43. /* Process commands. */
  44.  
  45. char push_cmd[80];
  46.  
  47. no_running()            /* make sure no process is running */
  48. {
  49. if (!another)
  50.     return 0;
  51. say("A process is already running.");
  52. to_buffer("process");
  53. point = size();
  54. return 1;
  55. }
  56.  
  57. command push() on cx_tab[CTRL('E')]
  58. {
  59. int error;
  60. char cmd[80], cmdline[90];
  61.  
  62. if (no_running())
  63.     return;
  64. cmdline[0] = 0;
  65. if (has_arg) {
  66.     get_string(cmd, "Push With Command: ");
  67.     if (*cmd)
  68.         strcpy(push_cmd, cmd);
  69.     if (*push_cmd)
  70.         sprintf(cmdline, "/c %s", push_cmd);
  71. }
  72. iter = 0;
  73. build_first = 1;
  74. term_position(0, 23);
  75. error = shell(getenv("COMSPEC"), cmdline);
  76. if (cmdline[0]) {
  77.     if (!char_avail())
  78.         sayput("Press any key to return to Epsilon");
  79.     getkey();
  80. }
  81. say(error ? "Couldn't exec": "");
  82. }
  83.  
  84. command start_process() on cx_tab[CTRL('M')]
  85. {
  86. int error = 0;
  87. char cmd[80], cmdline[90];
  88.  
  89. if (no_running())
  90.     return;
  91. cmdline[0] = 0;
  92. if (has_arg) {
  93.     get_string(cmd, "Start Process With Command: ");
  94.     if (*cmd)
  95.         strcpy(push_cmd, cmd);
  96.     if (*push_cmd)
  97.         sprintf(cmdline, "/c %s", push_cmd);
  98. }
  99. zap("process");
  100.  
  101. error = concur_shell(getenv("COMSPEC"), cmdline);
  102. iter = 0;
  103. if (error)
  104.     say("Couldn't exec");
  105. else
  106.     to_buffer("process");
  107. }
  108.  
  109. command stop_process() on reg_tab[CTRL('C')]
  110. {
  111. halt_process(has_arg);
  112. iter = 0;
  113. }
  114.  
  115. command next_error() on cx_tab[CTRL('N')]
  116. /* [1]
  117.  *  Find the next error message in the process buffer.  The format of
  118.  *  the error is deduced from buffer-specific variables; this routine
  119.  *  should be called from a buffer of the right language!
  120.  */
  121. {
  122.     char *orig = bufname, file[FNAMELEN], number[30], line[130];
  123.     int lineno, origpt, dir, orig_num = window_number, old;
  124.     char *er=error_recog, *ef=erfile_recog, *el=erline_recog;
  125.                 /* [1] Local copies */
  126.  
  127.     if (!exist("process"))
  128.         error("No process buffer to read errors from.");
  129.     bufname = "process";
  130.     error_recog = er;    /* /[1] Copy to process buffer */
  131.     erfile_recog = ef;
  132.     erline_recog = el;
  133.     origpt = point;
  134.     if (error_spot)
  135.         point = *error_spot;
  136.     else {
  137.         error_spot = alloc_spot();
  138.         point = 0;
  139.     }
  140.     sayput("Searching...");
  141.     for (; iter; iter -= dir) {
  142.         dir = (iter > 0) ? 1 : -1;
  143.         old = point;
  144.         if (!re_search(dir, er)) {
  145.             *error_spot = old;
  146.             point = origpt;
  147.             bufname = orig;
  148.             say("No more errors");
  149.             iter = 0;
  150.             return;
  151.         }
  152.     }
  153.     to_begin_line();    /* [1] */
  154.     re_search(1, ef);    /* [1] Find file name */
  155.     grab (find_group (1, 1), find_group (1, 0), file);
  156.                 /* [1] Abstract the name */
  157.     re_search(1, el);    /* [1] Find line number */
  158.     grab (find_group (1, 1), find_group (1, 0), number);
  159.                 /* [1] Abstract the line number */
  160.     to_begin_line();    /* [1] Now pick up whole line */
  161.     parse_string (1, ".*", line);
  162.     *error_spot = point;
  163.     point = origpt;
  164.     lineno = strtoi(number, 10);
  165.     absolute(file);
  166.  
  167.     bufname = orig;
  168.     window_number = 0;
  169.     do {
  170.         if (!strcmp(filename, file))
  171.             orig_num = window_number;
  172.         window_number++;
  173.     } while (window_number);
  174.     window_number = orig_num;
  175.     find_it(file);
  176.     go_line(lineno);
  177.     say("=>%.78s", line);
  178. }
  179.